package webengine

import (
	"github.com/gin-gonic/gin"
	"strings"
)

// GetHandlerLastMethod 获取请求的方法最后一个方法名
func GetHandlerLastMethod() gin.HandlerFunc {

	return func(context *gin.Context) {
		HandlerName := context.HandlerName()
		HandlerNameArray := strings.Split(HandlerName, ".")
		handlerLastMethod := strings.ReplaceAll(HandlerNameArray[len(HandlerNameArray)-1], "-fm", "")
		context.Set("handlerLastMethod", handlerLastMethod)
		context.Next()
	}
}
